package com.game.raceroom.player.effect
{
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.utils.getTimer;
	
	import com.game.raceroom.player.Player;
	public class BloodEffect extends Effect
	{   
		private var eftText:TextField;
		private var actor:Player;
        private var format:TextFormat= new TextFormat();
	    public static var crashFilter:GlowFilter = 
		 new GlowFilter(0xFFFFFF, 0.7, 2,2, 10, 1, false, false);  

		public function BloodEffect(actor:Player,level:int,dec:int)
		{  
			this.actor=actor;
			this.effectType=level;
			startTime=getTimer();
			maxTime=2000;
			eftText=new TextField;
			eftText.text="-"+dec;
			eftText.filters=[crashFilter];
//			if(level==1){
//				msgtxt.scaleY=1.2;
//				msgtxt.scaleX=1.2;
//			}
//			if(level==2){
//				msgtxt.scaleY=1.5;
//				msgtxt.scaleX=1.5;
//			}
//			if(level==3){
//				msgtxt.scaleY=1.8;
//				msgtxt.scaleX=1.8;
//			}
       		format.color = 0xFF3030;
       		format.size=24;
            format.font = "Bold";               
            eftText.setTextFormat(format);
            
 
			
		    eftText.x=(actor.actorDisp.mc.width-eftText.width)/2+actor.actorDisp.mc.x;
			eftText.y=actor.actorDisp.mc.y;
		    this.actor.actorDisp.addChild(eftText);
		 }
         public function getShowStep():int{
         	var time:int=getTimer()-startTime;
 
         	if(time>maxTime)return 999;
         	else
         	 return time/50;
         	return 0;
         }
         private function zoom(scale:Number):void{
         	if(this.effectType==EFFECT_TYPE_UNDER_ATK){
         		
         	}else
            if(this.effectType==EFFECT_TYPE_UNDER_FATAL_ATK_L1){
         		eftText.scaleX=scale;
         		eftText.scaleY=scale;
         	}else
         	if(this.effectType==EFFECT_TYPE_UNDER_FATAL_ATK_L1){
         		eftText.scaleX=scale+0.5;
         		eftText.scaleY=scale+0.5;
         	}else
         	if(this.effectType==EFFECT_TYPE_UNDER_FATAL_ATK_L1){
         		eftText.scaleX=scale+1;
         		eftText.scaleY=scale+1;
         	}
         }
         public override function update():Boolean{
			
			eftText.y=actor.actorDisp.mc.y-(getTimer()-startTime)/30;
         	 var step:int=getShowStep();
         	 switch(step){
         	 	case 0:
         	 	   break;
         	 	case 1:
         	 	   zoom(1.1);
         	 	   break;
                case 2:
                   zoom(1.3);
         	 	   break;
                case 4:
                   zoom(1.5);
                   break;
                case 5:
                case 6:
                   zoom(1.8);
         	 	   break;
                case 7:
                   zoom(1.6);
                   break;
                case 8:
                case 9:
                case 10:
                   zoom(1.8);
                   break;
                case 11:
                case 12:
                   zoom(1.5);
         	 	   break;
                case 13:
                   zoom(1.3);
         	 	   break;
                case 14:
                   zoom(1.1);
         	 	   break;
         	    case 999:
         	       actor.actorDisp.removeChild(eftText);
         	       eftText=null;
         	        valid=false;
         	        break;
         	 }
         	 if(eftText)
         	 	eftText.x=(actor.actorDisp.mc.width-eftText.width)/2+actor.actorDisp.mc.x;
        	 return true;
         }
	}
}